<?php
include_once "conn.php";
$n=is_numeric($_GET['n'])?$_GET['n']:exit('No Net!');

function sendly($uin,$sid,$con){
	$url = "http://m.qzone.com/msgb/fcg_add_msg";
	$post = "res_uin={$uin}&format=json&content={$con}&opr_type=add_comment&sid={$sid}";
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL,$url);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	$json = curl_exec($ch);
	curl_close($ch);
	$arr=json_decode($json,true);
	if($arr[code]==-3000){
		return 'SID';
	}else{
		return $json;
	}
}

$rs = $db->query("SELECT * FROM ".DB_PREFIX."qqs where isly>0 and (nextly<'$now' or nextly IS NULL) and sidzt=0");
while($row=$rs->fetch()){ 
	if($config['crontype']){
		$qid=$row['qid'];
		$uin=$row['qq'];
		$next=date("Y-m-d H:i:s",time()+60*10-10);
		@$db->exec("update ".DB_PREFIX."qqs set lastly='$now',nextly='$next' where qid='$qid'");
		
		$rs2 = $db->query("SELECT sid,qid FROM ".DB_PREFIX."qqs where sidzt=0 order by rand() limit 2");
		while($qq=$rs2->fetch()){
			$con=get_con();
			$get=sendly($uin,$qq['sid'],$con);
			if($get=='SID'){
				@$db->exec("UPDATE ".DB_PREFIX."qqs SET sidzt='1',skeyzt='1' WHERE qid='{$qq['qid']}'");
			}
			if($_GET['get']==1){
				echo $get;
			}
		}
	}else{
		$urls[]="{$nurl}ly.run.php?cron=".$_GET['cron']."&qid={$row['qid']}{$look}";
	}
}

if(!$config['crontype']){
	if($urls){
		$get=duo_curl($urls);
	}
	if($_GET['get']==1){
		print_r($get);
	}
}
exit('Ok!');


